package com.order.config;

import me.chanjar.weixin.mp.api.WxMpConfigStorage;
 import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
 import me.chanjar.weixin.mp.api.WxMpService;
 import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Component;
 @Component
public class WechatMpConfig {

         @Autowired
 WechatAccountConfig accountConfig;

         @Bean
         public WxMpService wxMpService() {
         WxMpService wxMpService = new WxMpServiceImpl();
         WxMpInMemoryConfigStorage wxMpConfigStorage = new WxMpInMemoryConfigStorage();
         String mpAppId = accountConfig.getMpAppId();
         String mpAppSecret = accountConfig.getMpAppSecret();
         wxMpConfigStorage.setAppId(mpAppId);
         wxMpConfigStorage.setSecret(mpAppSecret);
         wxMpService.setWxMpConfigStorage(wxMpConfigStorage);
         return wxMpService;
         }

 }